#include <iostream>

using namespace std;

//左 根 右
//根 左 右

//求：左 右 根

string s1, s2;

void dfs(int l1, int r1, int l2, int r2)
{
	if(l1 > r1) return;

	//1.确定根节点
	int p = l1;
	for(int i = l1; i <= r1; i++)
	{
		if(s1[i] == s2[l2]) p = i;
	}

	//2.划分左右子树
	dfs(l1, p - 1, l2 + 1, l2 + p - l1);
	dfs(p + 1, r1, l2 + p - l1 + 1, r2);

	cout << s2[l2];
}

int main()
{
	cin >> s1 >> s2;

	dfs(0, s1.size() - 1, 0, s2.size() - 1);

	return 0;
}

